<template>
  <div class="time-line">
    <div
      :class="list.length - 1 !== index ? 'flex-1' : ''"
      class="flex"
      v-for="(item, index) in list"
      :key="index"
    >
      <div
        :class="active === index ? 'highlight' : 'grey-out'"
        class="breakpoint-body flex-column flex-yx-center"
      >
        <div class="breakpoint">
          <div class="breakpoint-layer">{{ index + 1 }}</div>
        </div>
        <div class="breakpoint-title">{{ item }}</div>
      </div>
      <div class="time-line_border" v-if="list.length - 1 !== index"></div>
    </div>
  </div>
</template>
<script setup>
import { ref } from "vue";
const props = defineProps({
  active: {
    type: Number,
    default: 0,
  },
  list: {
    type: Array,
    default: ["验证身份", "设置密码", "完成"],
  },
});
</script>
<style lang="less" scoped>
.breakpoint-body {
  position: relative;
}
.time-line {
  display: flex;
  .highlight {
    .breakpoint {
      background: rgba(58, 133, 245, 0.2);
    }

    .breakpoint-layer {
      background: #3a85f5;
    }
    .breakpoint-title {
      color: rgba(0, 0, 0, 0.85);
    }
  }
  .grey-out {
    .breakpoint {
      background: rgba(204, 204, 204, 0.2);
    }
    .breakpoint-layer {
      background: #cccccc;
    }
    .breakpoint-title {
      color: #8c8c8c;
    }
  }
  .time-line_title {
    font-size: 16px;
    color: rgba(0, 0, 0, 0.85);
    text-align: center;
    margin-top: 12px;
  }
  .time-line_border {
    flex: 1;
    height: 1px;
    background: #e9e9e9;
    margin-top: 20px;
    margin-right: 8px;
    margin-left: 8px;
  }
  .breakpoint-title {
    font-size: 16px;
    color: rgba(0, 0, 0, 0.85);
    position: absolute;
    top: 50px;
    width:200px;
    text-align: center;
}
  .breakpoint {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    .breakpoint-layer {
      width: 30px;
      height: 30px;
      border-radius: 15px;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 16px;
    }
  }
}
</style>